1 Introduction

This document is devoted to explain how the dirinla package deal with random effects. The main idea is to show the idea, depict how it has been implemented, and lastly, show some results.

2 Theoretical idea

2.1 Dirichlet regression

Let \({\boldsymbol{Y}}\) be a matrix with \(C\) rows and \(N\) columns denoting \(N\) observations for the different categories \(C\) of the \(C\) dimensional response variable \({\boldsymbol{Y}}_{\bullet n} \sim \mathcal{D}({\boldsymbol{\alpha}}_n)\). Let \(\eta_{cn}\) be the linear predictor for the \(n\)th observation in the \(c\)th category, so \({\boldsymbol{\eta}}\) is a matrix with \(C\) rows and \(N\) columns. Let \({\boldsymbol{V}}^{(c)}\), \(c=1, \ldots, C\), represents a matrix with dimension \(N \times J_c\) that contains the covariate values for each individual and each category, so \({\boldsymbol{V}}^{(c)}_{n \bullet}\) shows the covariate values for the \(n\)th observation and the \(c\)th category. Let \({\boldsymbol{\beta}}\) be a matrix with \(J_c\) rows and \(C\) columns representing the regression coefficients in each dimension, then the relationship between the parameters of the Dirichlet distribution and the covariates is set up as: \[\begin{equation}\label{eq:dirichlet_regression} g(\alpha_{cn}) = \eta_{cn} = {\boldsymbol{V}}^{(c)}_{n\bullet} {\boldsymbol{\beta}}^{c} \,\,, \end{equation}\] where \(g(\cdot)\) is the link-function. As \(\alpha_c>0\) for \(c = 1,\ldots,C\), log-link \(g(\cdot) = \log(\cdot)\) is used. {The regression coefficients \({\boldsymbol{\beta}}^{(c)}\) are a column vector with \(J_c\) elements}.

The main idea of this document is to show how we are able to introduce random effects in the formula. To show how it works, we show an example where we include two different random effects. Both are shared by two components. \[\begin{eqnarray}\label{eq:dirichlet_regression2} g(\alpha_{1n}) & = & \eta_{1n} = {\boldsymbol{V}}^{(c)}_{n\bullet} {\boldsymbol{\beta}}^{1} + w^{1}_{n}\,\,, \nonumber \\ g(\alpha_{2n}) & = & \eta_{2n} = {\boldsymbol{V}}^{(c)}_{n\bullet} {\boldsymbol{\beta}}^{2} + w^{1}_{n}\,\,, \nonumber \\ g(\alpha_{3n}) & = & \eta_{3n} = {\boldsymbol{V}}^{(c)}_{n\bullet} {\boldsymbol{\beta}}^{3} + w^{2}_{n}\,\,, \nonumber \\ g(\alpha_{4n}) & = & \eta_{4n} = {\boldsymbol{V}}^{(c)}_{n\bullet} {\boldsymbol{\beta}}^{4} + w^{2}_{n}\,\,, \nonumber \\ \nonumber \\ {\boldsymbol{w}}^{1} & \sim & \mathcal{N}(0, \tau_1) \,, \ {\boldsymbol{w}}^{2} \sim \mathcal{N}(0, \tau_2) \nonumber \\ \end{eqnarray}\]

Previous equation can be rewritten in a vectorized form. In particular, if \[{\boldsymbol{\tilde{\eta}}}= \underbrace{\begin{bmatrix} {\boldsymbol{\eta}}_{\bullet 1} \\ \vdots \\ {\boldsymbol{\eta}}_{\bullet N} \end{bmatrix}}_{CN \times 1} \, \ \] denotes a restructured linear predictor, being \({\boldsymbol{\eta}}_{\bullet n}\) a column vector representing the linear predictor for the \(n\)th observation and all the categories, the model in matrix notation is (without priors): \[\begin{equation}\label{eq:dirichlet_regression_matricial} {\boldsymbol{\tilde{\eta}}} = {\boldsymbol{A}} {\boldsymbol{x}}(\tau_1, \tau_2) \,, \end{equation}\] where \({\boldsymbol{A}}\) is the matrix with covariates properly constructed with \(CN\) rows and j (elements of the latent field) columns and \({\boldsymbol{x}}(\tau_1, \tau_2)\) the elements of the latent Gaussian field. Some of them come from the iid effect and depends on the hyperpars \(\tau_1\) and \(\tau_2\). When we write \({\boldsymbol{\theta}}\) we are refering to the vector \((\sigma_1, \sigma_2)\).

2.2 Objectives

As INLA can not deal with multivariate likelihood, the challenge is measure the effect of the likelihood on the posterior and get \(p( {\boldsymbol{x}} \mid {\boldsymbol{y}})\) and \(p( {\boldsymbol{\theta}} \mid {\boldsymbol{y}})\).

2.3 Aproximating INLA for Dirichlet regression

All here depicted is based on the INLA method for non-linear predictors from the inlabru R-package (https://inlabru-org.github.io/inlabru/articles/method.html).

The dirichlet likelihood is approximated by conditional independent gaussian, \({\boldsymbol{\tilde{z}_0}}\) (see https://arxiv.org/pdf/1907.04059.pdf section 4). \[{\boldsymbol{\tilde{z}_0}} \mid {\boldsymbol{\tilde{\eta}}} \sim \mathcal{N}({\boldsymbol{L_{0}}}^T {\boldsymbol{\tilde{\eta}}}, {\boldsymbol{I_{CN}}})\,.\] Then: \[p({\boldsymbol{y}} \mid {\boldsymbol{x}}, {\boldsymbol{\theta}}) = p( {\boldsymbol{y}} \mid \tilde{\eta}) \approx p({\boldsymbol{z}} \mid \tilde{\eta}) = p({\boldsymbol{z}} \mid {\boldsymbol{x}}, {\boldsymbol{\theta}}) \,.\] The model posterior is factorised as: \[p({\boldsymbol{\theta}}, {\boldsymbol{x}} \mid {\boldsymbol{y}}) = p({\boldsymbol{\theta}} \mid {\boldsymbol{y}}) \cdot p({\boldsymbol{x}} \mid {\boldsymbol{y}}, {\boldsymbol{\theta}}) \,,\] and the approximation is factorised as: \[\overline{p}({\boldsymbol{\theta}}, {\boldsymbol{x}} \mid {\boldsymbol{\tilde{z}_0}}) = \overline{p}({\boldsymbol{\theta}} \mid {\boldsymbol{\tilde{z}_0}}) \cdot \overline{p}({\boldsymbol{x}} \mid {\boldsymbol{\tilde{z}_0}}, {\boldsymbol{\theta}}) \,,\]

3 Computational implementation

This section is devoted to explain how the algorithm works. The main function is dirinlareg. One of the key point is that the observation model is linked to \({\boldsymbol{x}}\) only through the linear predictor.` To show how it works, we are going to do an example step by step.

3.1 Simulating data

We use a simple example where we include four different categories with four different covariates and a common random effect, i.e., \[\begin{eqnarray} \log(\alpha_{1n}) & = & \eta_{1n} = \beta_{1}^1 \cdot v_{1n} + w^1(j_n) \,, \nonumber \\ \log(\alpha_{2n}) & = & \eta_{2n} = \beta_{1}^2 \cdot v_{2n} + w^1(j_n) \,, \nonumber \\ \log(\alpha_{3n}) & = & \eta_{3n} = \beta_{1}^3 \cdot v_{3n} + w^2(j_n) \,, \nonumber \\ \log(\alpha_{4n}) & = & \eta_{4n} = \beta_{1}^4 \cdot v_{4n} + w^2(j_n) \,, \nonumber \\ \end{eqnarray}\] where \(v_{kn}\) are covariates \(k = 1, \ldots, 4\) simulated from a random uniform (-1, 1), and \(w^1(j_n)\) and \(w^2(j_n)\) are iid shared random effects. \(j_n = 1, \ldots, J\), being \(J\) the levels of the factor. In the example, we assume that \(J = 25\).

n <- 50
levels_factor <- 25
set.seed(100)
  if(is.na(levels_factor)){
    levels_factor <- n
  }
  cat_elem <- n/levels_factor
  cat(paste0(n, "-", levels_factor, "\n"))
  #Covariates
  V <- as.data.frame(matrix(runif((10)*n, -1, 1), ncol=10))
  #V <- as.data.frame(matrix(rnorm((10)*n, 0, 1), ncol=10))
  names(V) <- paste0('v', 1:(10))

  ### 4 random effects
  iid1 <- iid2  <- rep(1:levels_factor, rep(n/levels_factor, levels_factor))
  #Desorder index 3
  # pos <- sample(1:length(iid3))
  # iid3 <- iid3[pos]

  V <- cbind(V, iid1, iid2)

  # Formula that we want to fit
  formula <- y ~ -1 + v1 + f(iid1, model = 'iid') |
    -1 + v2 + f(iid1, model = 'iid') |
    -1 + v3 + f(iid2, model = 'iid') |
    -1 + v4 + f(iid2, model = 'iid')
  names_cat <- formula_list(formula)

  x <- c(-1.5, 2,
         1, -3)

  #random effect
  prec_w <- c(4, 9)
  (sd_w <- 1/sqrt(prec_w))

  w1 <- rnorm(levels_factor, sd = sqrt(1/prec_w[1])) %>% rep(., rep(n/levels_factor, levels_factor))
  w2 <- w1
  w3 <- rnorm(levels_factor, sd = sqrt(1/prec_w[2])) %>% rep(., rep(n/levels_factor, levels_factor))
  w4 <- w2


  #w3 <- w3[pos]
  x <- c(x, c(unique(w1),
              unique(w3)))


  d <- length(names_cat)
  A_construct <- data_stack_dirich(y          = as.vector(rep(NA, n*d)),
                                   covariates = names_cat,
                                   share      = NULL,
                                   data       = V,
                                   d          = d,
                                   n          = n )

  # Ordering the data with covariates --- ###
  eta <- A_construct %*% x
  alpha <- exp(eta)
  alpha <- matrix(alpha,
                  ncol  = d,
                  byrow = TRUE)
  y_o <- rdirichlet(n, alpha)
  colnames(y_o) <- paste0("y", 1:d)


  y <- y_o

3.1.1 Response

head(as.data.frame(y))

3.1.2 Covariates

V[,c(1:4, 11)]

3.2 Steps for the computation

  1. Set the initial point for the latent field

    A <- A_construct
    x0 <- rep(0, dim(A)[2])
    x0
    #>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    #> [39] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  2. Line search. Note that, in order to do the line search, the A matrix has to be constructed. In the case of the example, is depicted below:

      head(A)
    #> 6 x 54 sparse Matrix of class "dgCMatrix"
    #>                                                                               
    #> [1,] -0.3844678  .          .         .          1 . . . . . . . . . . . . . .
    #> [2,]  .         -0.3389403  .         .          1 . . . . . . . . . . . . . .
    #> [3,]  .          .         -0.3451698 .          . . . . . . . . . . . . . . .
    #> [4,]  .          .          .         0.01017252 . . . . . . . . . . . . . . .
    #> [5,] -0.4846550  .          .         .          1 . . . . . . . . . . . . . .
    #> [6,]  .         -0.6026419  .         .          1 . . . . . . . . . . . . . .
    #>                                                                           
    #> [1,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    #> [2,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    #> [3,] . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . .
    #> [4,] . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . .
    #> [5,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    #> [6,] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Line search is run at maximum of 10 iterations, and imposing a condition in the gradient and in the difference of posteriors. The function that do it is look_for_mode_x.

  3. Prepare formula and matrix A to call inla. Now, the matrix A is just the identity matrix:

      d <- 4
    data_stack_2 <- data_stack_dirich_formula(y          = NA,
                                              covariates = names_cat,
                                              share      = NULL,
                                              data       = V,
                                              d          = d,
                                              n          = n )
    
      A <- data_stack_2[[1]]

    and the formula is constructed as:

      data_stack_2$formula.inla
    #> category ~ -1 + f(cat1_v1, model = "linear") + f(cat2_v2, model = "linear") + 
    #>     f(cat3_v3, model = "linear") + f(cat4_v4, model = "linear") + 
    #>     f(iid1, model = "iid") + f(iid2, model = "iid")
    #> A = numeric(1)
    #> covariates = list(4)
    #> covariatesall = list(4)
    #> d = numeric(1)
    #> data = data.frame(50,13)
    #> effects = data.frame(200,6)
    #> effects_random = list(2)
    #> formula.inla = formula(3)
    #> formula.inla.pred = character(1)
    #> formula.inla.pred2 = character(1)
    #> index_mat = dgeMatrix(8)
    #> index_random_names = character(2)
    #> n = numeric(1)
    #> names_inla_fixed = character(4)
    #> random_eff = list(4)
    #> random_eff_args = list(4)
    #> share = NULL(0)
    #> y = logical(1)

    being each element incorporated as effect using different index:

    data_stack_2[[1]]$effects$data %>% head(.)
  4. Call inla to obtain \(\overline{p}({\boldsymbol{\theta}} \mid {\boldsymbol{\tilde{z}_0}})\) and \(\overline{p}({\boldsymbol{x}} \mid {\boldsymbol{\tilde{z}_0}}) \,,\)

  5. If in step 2, algorithm has converged, we have finished. If not, we define we define a new initial point with the mode of the posterior distributions given by inla.

4 Tests

4.1 Simulation

To conduct the tests, I have simulated different datasets with the following structures. Each dataset has 4 covariates, one per category and a shared random effect. \[\begin{eqnarray} \log(\alpha_{1n}) & = & \eta_{1n} = \beta_{1}^1 \cdot v_{1n} + w^1(j_n) \,, \nonumber \\ \log(\alpha_{2n}) & = & \eta_{2n} = \beta_{1}^2 \cdot v_{2n} + w^1(j_n) \,, \nonumber \\ \log(\alpha_{3n}) & = & \eta_{3n} = \beta_{1}^3 \cdot v_{3n} + w^2(j_n) \,, \nonumber \\ \log(\alpha_{4n}) & = & \eta_{4n} = \beta_{1}^4 \cdot v_{4n} + w^2(j_n) \,, \nonumber \\ \end{eqnarray}\] where \(v_{kn}\) are covariates \(k = 1, \ldots, 4\) simulated from a random uniform (-1, 1), and \(w^1(j_n)\) and \(w^2(j_n)\) are iid shared random effects. \(j_n = 1, \ldots, J\), being \(J\) the levels of the factor.

We simulate datasets with N= 50, 100 and 500; and with different sizes for J. We have fitted the models using Gaussian priors for \(\beta\)s, Half Normal and pc-priors for \(\sigma_1\) and \(\sigma_2\). We are going to fit four different models:

  1. Short-JAGS with Half Normal for standard deviations (mean = 0, sd = 1).

  2. dirinla with pc-priors for standard deviations (sigma = 10, alpha = 0.01).

  3. Long-JAGS with Half Normal for standard deviations (mean = 0, sd = 1).

  4. dirinla with Half Normal for standard deviations (mean = 0, sd = 1).

In order to check the results, we have computed:

  • Posterior distributions and have compared it.

  • Computational times

  • Mean and sd of the fixed effects

  • Two measures: \(ratio_1\) (closer 0, better is the dirinla fit) and \(ratio_2\) (closer 1, better is the dirinla fit), computed for the parameters and hyperparameters: \[\begin{eqnarray}\label{eq:ratio1_ratio2} ratio_1 & = & (E(\phi_{dirinla}) - E(\phi_{long R-JAGS}))/ SD(\phi_{long R-JAGS}) \,\,, \\ ratio_2 & = & SD(\phi_{dirinla})/ SD(\phi_{long R-JAGS}) \,\,, \end{eqnarray}\]

  • \(n.eff\) and \(Rhat\) for short and long JAGS.

4.2 Results

summary_print <- function(N, J)
{
  cat("\n")
  cat(sprintf(paste0("#### J = ", J, "\n")))
  cat("**Parameters** \n")
  cat(paste0("![](IMG/examples_simulation4_slopes_", N, "_", J, "/examples_simulation4_slopes_", N, "_", J, "-1.png){width=100%}"))

  cat("**Hyperparameters** \n ")
  cat(paste0("![](IMG/examples_simulation4_sigma_", N, "_", J, "/examples_simulation4_sigma_", N, "_", J, "-1.png){width=100%} \n \n "))
  cat("<br>")
  if(N<=500)
  {
      a <- readRDS("simulation4_50-500.RDS")
  }else{
      a <- readRDS("simulation4_1000.RDS")
  }
  a <- a[, c(paste0(N, "-", J))]
  
  #Half normal
  # names(a)[c(7,8, 11, 12)] <- c("ratio1_sigma_pc", "ratio2_sigma_pc", "ratio1_sigma_log_hn", "ratio2_sigma_log_hn")
  
  

    
  num <- length(a) - 1
  names_ele <- names(a)
  names(a[[1]]) <- c("JAGS", "dirinla pc", "LONG-JAGS", "dirinla hn")
  names(a[c(13,14)]) <- c("res_check_jags", "res_check_long_jags")
  for (i in 1:num){
    b <- a[i]
    if(i == 2)
    {
      result <- as.numeric(b[[1]]) %>% matrix(., nrow = 4)
      colnames(result) <- colnames(b[[1]])
      colnames(result) <- c("JAGS_mean", "JAGS_sd", "INLA_PC_mean", "INLA_PC_sd", "LONG_JAGS_mean", "LONG_JAGS_sd", "INLA_HN_mean", "INLA_HN_sd")  
      rownames(result) <- rownames(b[[1]])
      
      result %>%  knitr::kable(.,  digits = c(4)) %>% 
        print(.)
    }else{
     cat(paste0("**", names_ele[i], "** \n "))
     b[[1]] %>% as.matrix(.) %>% t(.) %>% knitr::kable(.,  digits = c(4)) %>% print(.)
     cat("\n \n ")
    }
  }
}

4.2.1 N = 50

summary_print(N = 50, J = 2)

4.2.1.1 J = 2

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
86.44 24.36 4253.34 17.89
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5310 0.2567 -1.5414 0.2490 -1.5315 0.2583 -1.5415 0.2489
beta12 2.0258 0.2145 2.0424 0.2192 2.0254 0.2147 2.0425 0.2190
beta13 1.0751 0.2111 1.0982 0.1901 1.0766 0.2124 1.0988 0.1900
beta14 -2.9160 0.1876 -2.9481 0.1918 -2.9203 0.1869 -2.9490 0.1916

ratio1_beta1_pc

-0.0382 0.0795 0.1016 -0.1486

ratio1_beta1_hn

-0.0388 0.0798 0.1041 -0.1533

ratio2_beta1_pc

0.9246 1.0465 0.833 1.0529

ratio2_beta1_hn

0.9285 1.0509 0.8128 1.0532

ratio1_sigma_pc

sigma1 sigma2
0.0304 0.1802

ratio2_sigma_pc

sigma1 sigma2
1.2871 1.1437

ratio1_sigma_hn

sigma1 sigma2
0.0142 0.1565

ratio2_sigma_hn

sigma1 sigma2
1.2072 1.0707

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.0289 0.265

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.7877 0.5473

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0373 0.2622

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.7318 0.5177

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001 1.0009 1.0009 1.0013 1.0009 1.0045 1.0015
n.eff 11000.000 11000.0000 11000.0000 5100.0000 11000.0000 5700.0000 3100.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001
n.eff 5.400e+05 3.900e+05 2.500e+05 5.400e+05 5.400e+05 2.100e+05 61000.000

n_levels

50-2
summary_print(N = 50, J = 5)

4.2.1.2 J = 5

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
84.7 23.86 4334.2 20.95
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.3347 0.2569 -1.3089 0.2479 -1.3354 0.2578 -1.3089 0.2478
beta12 1.8220 0.2103 1.8295 0.2188 1.8212 0.2109 1.8287 0.2187
beta13 0.9425 0.1937 0.9586 0.1866 0.9413 0.1922 0.9582 0.1866
beta14 -2.7211 0.2003 -2.7397 0.2008 -2.7212 0.2003 -2.7391 0.2008

ratio1_beta1_pc

0.103 0.0394 0.09 -0.0925

ratio1_beta1_hn

0.1027 0.0357 0.0877 -0.0898

ratio2_beta1_pc

0.9217 1.0824 0.976 1.0029

ratio2_beta1_hn

0.9233 1.0869 0.9576 1.0077

ratio1_sigma_pc

sigma1 sigma2
-0.1074 0.0819

ratio2_sigma_pc

sigma1 sigma2
0.9862 1.1708

ratio1_sigma_hn

sigma1 sigma2
-0.1145 -0.0011

ratio2_sigma_hn

sigma1 sigma2
0.9156 0.9643

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.0769 0.0712

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.7606 1.0463

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0707 0.0064

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.7238 0.9531

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0009 1.0009 1.0009 1.0012 1.0015 1.0076 1.0009
n.eff 11000.0000 11000.0000 11000.0000 6600.0000 3100.0000 1700.0000 11000.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 4.400e+05 4.300e+05 1.200e+05 5.400e+05 5.400e+05 5.400e+05 3.800e+05

n_levels

50-5
summary_print(N = 50, J = 10)

4.2.1.3 J = 10

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
85.13 20.62 4228.33 21.36
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.4256 0.2390 -1.4354 0.2252 -1.4216 0.2416 -1.4361 0.2251
beta12 2.0345 0.2446 2.0971 0.2188 2.0308 0.2443 2.0976 0.2187
beta13 0.9472 0.1927 0.9651 0.1888 0.9475 0.1919 0.9651 0.1888
beta14 -2.4796 0.2092 -2.5756 0.1860 -2.4741 0.2113 -2.5755 0.1859

ratio1_beta1_pc

-0.0571 0.2712 0.0919 -0.4804

ratio1_beta1_hn

-0.06 0.2734 0.0917 -0.48

ratio2_beta1_pc

0.8642 0.806 1.0062 0.7746

ratio2_beta1_hn

0.8676 0.8095 0.9824 0.7762

ratio1_sigma_pc

sigma1 sigma2
0.0376 0.543

ratio2_sigma_pc

sigma1 sigma2
0.9205 0.8862

ratio1_sigma_hn

sigma1 sigma2
0.0071 0.541

ratio2_sigma_hn

sigma1 sigma2
0.8641 0.844

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.0603 0.5148

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.81 0.2177

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0363 0.5179

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.7799 0.2086

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0013 1.0009 1.0009 1.0019 1.0009 1.0013 1.0408
n.eff 4600.0000 11000.0000 11000.0000 2000.0000 11000.0000 5000.0000 140.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 2.500e+05 5.200e+05 5.400e+05 5.400e+05 5.400e+05 3.400e+05 1.200e+05

n_levels

50-10
summary_print(N = 50, J = 25)

4.2.1.4 J = 25

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
85.43 24.51 4258.83 27.08
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.6670 0.2697 -1.7341 0.2513 -1.6678 0.2718 -1.7340 0.2512
beta12 1.8052 0.2592 1.8206 0.2346 1.8047 0.2589 1.8205 0.2346
beta13 0.7890 0.2320 0.8647 0.1921 0.7878 0.2313 0.8645 0.1921
beta14 -3.3133 0.2003 -3.3610 0.1944 -3.3130 0.2005 -3.3609 0.1944

ratio1_beta1_pc

-0.244 0.0613 0.3325 -0.2394

ratio1_beta1_hn

-0.2435 0.0609 0.3315 -0.2388

ratio2_beta1_pc

0.851 0.8254 0.7176 0.9397

ratio2_beta1_hn

0.8542 0.8296 0.7002 0.9416

ratio1_sigma_pc

sigma1 sigma2
0.2252 -0.5005

ratio2_sigma_pc

sigma1 sigma2
0.9417 1.1101

ratio1_sigma_hn

sigma1 sigma2
0.2159 -0.4983

ratio2_sigma_hn

sigma1 sigma2
0.913 1.086

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.2309 -0.58

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.5614 1.4537

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.2264 -0.5731

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.5486 1.4191

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0011 1.001 1.0009 1.001 1.0014 1.0021 1.0019
n.eff 8800.0000 11000.000 11000.0000 11000.000 3600.0000 2600.0000 11000.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.0025 1.001e+00
n.eff 5.400e+05 5.400e+05 5.400e+05 5.400e+05 1.600e+05 19000.0000 5.400e+05

n_levels

50-25
summary_print(N = 50, J = 50)

4.2.1.5 J = 50

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
90.12 27.47 4452.67 26.69
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.9463 0.2607 -2.0426 0.2377 -1.9464 0.2603 -2.0426 0.2377
beta12 1.9259 0.2747 1.8217 0.2324 1.9295 0.2749 1.8219 0.2324
beta13 1.2146 0.2079 1.1080 0.1906 1.2192 0.2071 1.1079 0.1906
beta14 -2.9008 0.1871 -2.9768 0.1912 -2.9048 0.1874 -2.9766 0.1912

ratio1_beta1_pc

-0.3694 -0.3921 -0.5369 -0.3842

ratio1_beta1_hn

-0.3693 -0.3914 -0.5373 -0.3834

ratio2_beta1_pc

0.8279 0.7178 0.8805 1.0416

ratio2_beta1_hn

0.8342 0.722 0.8595 1.0404

ratio1_sigma_pc

sigma1 sigma2
0.1322 0.1228

ratio2_sigma_pc

sigma1 sigma2
0.7792 0.7058

ratio1_sigma_hn

sigma1 sigma2
0.1243 0.1557

ratio2_sigma_hn

sigma1 sigma2
0.7624 0.6984

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.1718 0.256

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.4282 0.2914

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.1675 0.2815

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.4209 0.2743

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0012 1.001 1.0015 1.0013 1.0045 1.0063 1.1323
n.eff 6500.0000 11000.000 3000.0000 4200.0000 540.0000 8600.0000 58.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.0033 1.0013
n.eff 5.400e+05 5.400e+05 5.400e+05 5.400e+05 1.300e+05 18000.0000 7700.0000

n_levels

50-50

4.2.2 N = 100

summary_print(N = 100, J = 2)

4.2.2.1 J = 2

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
182.01 16.52 8993.8 11.66
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.4677 0.1781 -1.4736 0.1785 -1.4648 0.1787 -1.4751 0.1785
beta12 1.8881 0.1324 1.8936 0.1427 1.8885 0.1334 1.8951 0.1426
beta13 1.1340 0.1761 1.1409 0.1739 1.1352 0.1762 1.1412 0.1738
beta14 -2.7319 0.1718 -2.7398 0.1789 -2.7313 0.1714 -2.7399 0.1788

ratio1_beta1_pc

-0.0487 0.0386 0.0322 -0.0496

ratio1_beta1_hn

-0.0576 0.0494 0.0339 -0.0502

ratio2_beta1_pc

0.9851 1.1534 1.0092 1.0859

ratio2_beta1_hn

0.9967 1.1581 0.9899 1.094

ratio1_sigma_pc

sigma1 sigma2
0.3601 0.4413

ratio2_sigma_pc

sigma1 sigma2
2.5098 2.9556

ratio1_sigma_hn

sigma1 sigma2
0.0087 -0.0305

ratio2_sigma_hn

sigma1 sigma2
1.1849 1.1101

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.232 0.2824

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
1.4307 1.4938

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0153 -0.0531

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
1.0868 1.0724

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001 1.001 1.0011 1.0011 1.0009 1.0009 1.0017
n.eff 11000.000 11000.000 7600.0000 7400.0000 11000.0000 11000.0000 2400.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 5.400e+05 5.400e+05 3.900e+05 1.400e+05 5.400e+05 4.800e+05 3.900e+05

n_levels

100-2
summary_print(N = 100, J = 5)

4.2.2.2 J = 5

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
178.59 18.83 8694.55 19.65
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.2893 0.1773 -1.2766 0.1717 -1.2869 0.1786 -1.2767 0.1716
beta12 2.0838 0.1264 2.0907 0.1327 2.0827 0.1266 2.0907 0.1327
beta13 0.9483 0.1519 0.9741 0.1549 0.9479 0.1528 0.9743 0.1549
beta14 -3.1886 0.1676 -3.1956 0.1537 -3.1885 0.1663 -3.1960 0.1537

ratio1_beta1_pc

0.0577 0.0627 0.1712 -0.043

ratio1_beta1_hn

0.0573 0.0629 0.1729 -0.0454

ratio2_beta1_pc

0.9132 1.1114 1.0648 0.8516

ratio2_beta1_hn

0.9188 1.1124 1.0469 0.8568

ratio1_sigma_pc

sigma1 sigma2
-0.0095 0.0769

ratio2_sigma_pc

sigma1 sigma2
1.0342 0.9118

ratio1_sigma_hn

sigma1 sigma2
-0.0619 0.0717

ratio2_sigma_hn

sigma1 sigma2
0.8992 0.8789

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.0218 0.1221

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
1.0689 0.7147

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0639 0.122

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9908 0.6975

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001 1.0012 1.0009 1.001 1.0011 1.001 1.0033
n.eff 11000.000 6100.0000 11000.0000 11000.000 7300.0000 11000.000 4600.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 5.400e+05 5.400e+05 5.400e+05 5.400e+05 4.100e+05 5.400e+05 3.000e+05

n_levels

100-5
summary_print(N = 100, J = 10)

4.2.2.3 J = 10

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
169.71 20.46 8523.84 20
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.7246 0.1731 -1.7354 0.1657 -1.7267 0.1739 -1.7352 0.1657
beta12 2.0154 0.1287 2.0169 0.1271 2.0127 0.1273 2.0170 0.1270
beta13 0.9611 0.1545 0.9841 0.1523 0.9611 0.1557 0.9839 0.1523
beta14 -3.0510 0.1638 -3.0667 0.1542 -3.0537 0.1640 -3.0664 0.1542

ratio1_beta1_pc

-0.0496 0.0327 0.1476 -0.0791

ratio1_beta1_hn

-0.0485 0.0334 0.1466 -0.0776

ratio2_beta1_pc

0.8974 1.0042 0.9922 0.882

ratio2_beta1_hn

0.908 1.0085 0.9732 0.889

ratio1_sigma_pc

sigma1 sigma2
0.079 0.0942

ratio2_sigma_pc

sigma1 sigma2
1.0579 0.993

ratio1_sigma_hn

sigma1 sigma2
-0.0072 0.0783

ratio2_sigma_hn

sigma1 sigma2
0.9312 0.949

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.0776 0.1056

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
1.0395 0.9101

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0022 0.0943

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9683 0.8837

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0009 1.001 1.001 1.0013 1.0009 1.0009 1.0013
n.eff 11000.0000 11000.000 11000.000 4800.0000 11000.0000 11000.0000 5000.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 4.600e+05 5.400e+05 5.400e+05 5.400e+05 5.400e+05 5.400e+05 5.400e+05

n_levels

100-10
summary_print(N = 100, J = 25)

4.2.2.4 J = 25

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
171.42 21.07 8552.03 16.39
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.4289 0.1759 -1.4926 0.1636 -1.4268 0.1769 -1.4926 0.1636
beta12 2.0190 0.1362 2.0410 0.1262 2.0218 0.1354 2.0413 0.1262
beta13 1.0814 0.1606 1.1473 0.1533 1.0818 0.1605 1.1472 0.1533
beta14 -3.0197 0.1655 -3.0657 0.1471 -3.0195 0.1669 -3.0652 0.1471

ratio1_beta1_pc

-0.3719 0.1425 0.4081 -0.2773

ratio1_beta1_hn

-0.3717 0.1443 0.4075 -0.2737

ratio2_beta1_pc

0.8482 0.8739 0.9473 0.7757

ratio2_beta1_hn

0.8558 0.8792 0.9262 0.7798

ratio1_sigma_pc

sigma1 sigma2
0.1888 0.8524

ratio2_sigma_pc

sigma1 sigma2
1.0002 0.7479

ratio1_sigma_hn

sigma1 sigma2
0.1554 0.8476

ratio2_sigma_hn

sigma1 sigma2
0.9636 0.7346

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.1933 0.6323

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.9173 0.2027

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.163 0.6306

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.8966 0.1998

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001 1.0009 1.0009 1.0009 1.0013 1.001 1.0157
n.eff 11000.000 11000.0000 11000.0000 11000.0000 5100.0000 11000.000 580.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001 1.001e+00 1.0083
n.eff 2.000e+05 5.400e+05 3.600e+05 5.400e+05 73000.000 5.400e+05 4000.0000

n_levels

100-25
summary_print(N = 100, J = 100)

4.2.2.5 J = 100

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
178.87 23.08 9050.28 23.94
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.7892 0.1922 -1.7381 0.1640 -1.7896 0.1929 -1.7383 0.1640
beta12 2.2428 0.1538 2.2201 0.1394 2.2419 0.1542 2.2206 0.1393
beta13 1.1452 0.1699 1.0795 0.1566 1.1456 0.1678 1.0788 0.1566
beta14 -3.0647 0.1783 -3.1410 0.1583 -3.0678 0.1769 -3.1401 0.1584

ratio1_beta1_pc

0.267 -0.1416 -0.3943 -0.4137

ratio1_beta1_hn

0.266 -0.1386 -0.3983 -0.4086

ratio2_beta1_pc

0.72 0.8248 0.9083 0.8039

ratio2_beta1_hn

0.7199 0.8275 0.8803 0.8013

ratio1_sigma_pc

sigma1 sigma2
0.4395 0.2891

ratio2_sigma_pc

sigma1 sigma2
0.6985 0.5968

ratio1_sigma_hn

sigma1 sigma2
0.4262 0.2969

ratio2_sigma_hn

sigma1 sigma2
0.6889 0.5892

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.4385 0.3258

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.5128 0.2043

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.4277 0.3313

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.5082 0.2006

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0016 1.0014 1.0029 1.001 1.0038 1.0016 1.0166
n.eff 2600.0000 4000.0000 970.0000 11000.000 670.0000 2800.0000 160.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001 1.001e+00 1.001 1.001e+00 1.0012
n.eff 5.400e+05 5.400e+05 73000.000 5.400e+05 61000.000 3.400e+05 11000.0000

n_levels

100-100

4.2.3 N = 500

summary_print(N = 500, J = 2)

4.2.3.1 J = 2

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
857.67 22.91 43141.23 16.48
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.4931 0.0622 -1.4950 0.0649 -1.4934 0.0623 -1.4948 0.0649
beta12 2.0117 0.0611 2.0134 0.0597 2.0116 0.0611 2.0131 0.0597
beta13 1.0572 0.0566 1.0593 0.0576 1.0581 0.0569 1.0593 0.0576
beta14 -3.0679 0.0557 -3.0696 0.0555 -3.0680 0.0563 -3.0696 0.0555

ratio1_beta1_pc

-0.0246 0.0301 0.0205 -0.0277

ratio1_beta1_hn

-0.0216 0.0255 0.021 -0.028

ratio2_beta1_pc

1.0802 0.9736 1.0439 0.98

ratio2_beta1_hn

1.0894 0.9838 1.0204 0.9751

ratio1_sigma_pc

sigma1 sigma2
0.9784 0.6641

ratio2_sigma_pc

sigma1 sigma2
4.6735 3.6745

ratio1_sigma_hn

sigma1 sigma2
0.0533 0.0854

ratio2_sigma_hn

sigma1 sigma2
1.1097 1.1906

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.6877 0.4716

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
1.7296 1.4915

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0522 0.0868

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
1.0059 0.9952

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0011 1.001 1.001 1.0009 1.001 1.0016 1.0013
n.eff 8700.0000 11000.000 11000.000 11000.0000 11000.000 2700.0000 4700.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 4.800e+05 5.400e+05 3.400e+05 4.900e+05 5.400e+05 5.400e+05 2.300e+05

n_levels

500-2
summary_print(N = 500, J = 5)

4.2.3.2 J = 5

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
895.82 26.27 44329.66 24.28
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.4669 0.0624 -1.4687 0.0626 -1.4674 0.0618 -1.4687 0.0626
beta12 1.9733 0.0576 1.9753 0.0568 1.9742 0.0581 1.9753 0.0568
beta13 0.9054 0.0614 0.9071 0.0639 0.9057 0.0620 0.9071 0.0639
beta14 -2.9685 0.0599 -2.9706 0.0588 -2.9693 0.0592 -2.9705 0.0588

ratio1_beta1_pc

-0.0206 0.0189 0.0226 -0.0211

ratio1_beta1_hn

-0.0211 0.0197 0.0222 -0.0194

ratio2_beta1_pc

1.0194 0.9675 1.0809 0.9859

ratio2_beta1_hn

1.0309 0.9902 1.0637 0.9901

ratio1_sigma_pc

sigma1 sigma2
0.2251 -0.0265

ratio2_sigma_pc

sigma1 sigma2
1.3176 0.7906

ratio1_sigma_hn

sigma1 sigma2
0.0287 -0.0144

ratio2_sigma_hn

sigma1 sigma2
0.9427 0.7998

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.2123 -0.0064

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
1.1331 0.9152

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0393 0.0076

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9575 0.9155

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0011 1.001 1.0009 1.001 1.0009 1.0009 1.0009
n.eff 7300.0000 11000.000 11000.0000 11000.000 11000.0000 11000.0000 11000.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001 1.001e+00
n.eff 5.100e+05 5.400e+05 5.400e+05 4.100e+05 5.400e+05 93000.000 3.100e+05

n_levels

500-5
summary_print(N = 500, J = 10)

4.2.3.3 J = 10

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
859.89 27.76 43231.97 24.61
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5244 0.0609 -1.5291 0.0614 -1.5246 0.0614 -1.5291 0.0614
beta12 2.0027 0.0570 2.0042 0.0574 2.0028 0.0570 2.0043 0.0574
beta13 0.9601 0.0632 0.9613 0.0629 0.9596 0.0634 0.9613 0.0629
beta14 -3.0030 0.0575 -3.0072 0.0577 -3.0035 0.0577 -3.0072 0.0577

ratio1_beta1_pc

-0.0738 0.0245 0.027 -0.0642

ratio1_beta1_hn

-0.0743 0.025 0.0268 -0.0633

ratio2_beta1_pc

0.9969 1.0323 1.0038 1.0101

ratio2_beta1_hn

1.0069 1.0457 0.9799 1.0075

ratio1_sigma_pc

sigma1 sigma2
0.0534 -0.0205

ratio2_sigma_pc

sigma1 sigma2
0.9511 0.8939

ratio1_sigma_hn

sigma1 sigma2
0.013 -0.0113

ratio2_sigma_hn

sigma1 sigma2
0.893 0.8955

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.0615 -0.0136

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.9726 0.9556

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0234 -0.0033

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9374 0.9526

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0016 1.0011 1.001 1.001 1.001 1.0009 1.0009
n.eff 2500.0000 8800.0000 11000.000 11000.000 11000.000 11000.0000 11000.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 5.400e+05 5.400e+05 2.300e+05 5.400e+05 5.400e+05 4.500e+05 5.400e+05

n_levels

500-10
summary_print(N = 500, J = 25)

4.2.3.4 J = 25

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
861.24 24.5 43212.64 22.48
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5330 0.0655 -1.5410 0.0636 -1.5340 0.0654 -1.5410 0.0636
beta12 2.0678 0.0599 2.0721 0.0578 2.0672 0.0596 2.0721 0.0578
beta13 1.0241 0.0625 1.0294 0.0616 1.0242 0.0626 1.0294 0.0616
beta14 -3.0033 0.0621 -3.0137 0.0583 -3.0044 0.0617 -3.0137 0.0583

ratio1_beta1_pc

-0.107 0.0808 0.0835 -0.15

ratio1_beta1_hn

-0.1071 0.0811 0.0835 -0.1498

ratio2_beta1_pc

0.9402 0.9586 0.9846 0.9014

ratio2_beta1_hn

0.9513 0.9736 0.9605 0.8968

ratio1_sigma_pc

sigma1 sigma2
0.029 0.0559

ratio2_sigma_pc

sigma1 sigma2
0.9632 0.9682

ratio1_sigma_hn

sigma1 sigma2
0.0184 0.0596

ratio2_sigma_hn

sigma1 sigma2
0.9482 0.9666

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.0322 0.0603

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.973 0.9628

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0223 0.0642

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9618 0.9599

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001 1.001 1.0009 1.0009 1.0012 1.001 1.001
n.eff 11000.000 11000.000 11000.0000 11000.0000 6700.0000 11000.000 11000.000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 3.700e+05 5.400e+05 5.400e+05 5.400e+05 5.400e+05 2.000e+05 5.400e+05

n_levels

500-25
summary_print(N = 500, J = 500)

4.2.3.5 J = 500

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
918.89 27.8 46139.69 28.42
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.3821 0.0727 -1.4206 0.0655 -1.3825 0.0725 -1.4206 0.0655
beta12 2.0684 0.0657 2.1061 0.0610 2.0676 0.0655 2.1062 0.0610
beta13 1.1385 0.0673 1.1908 0.0621 1.1382 0.0669 1.1907 0.0621
beta14 -2.9930 0.0659 -3.0641 0.0601 -2.9924 0.0647 -3.0640 0.0601

ratio1_beta1_pc

-0.5255 0.5879 0.7854 -1.1078

ratio1_beta1_hn

-0.5261 0.589 0.7848 -1.107

ratio2_beta1_pc

0.8076 0.8833 0.862 0.8466

ratio2_beta1_hn

0.8221 0.9023 0.8802 0.8727

ratio1_sigma_pc

sigma1 sigma2
0.8772 0.9221

ratio2_sigma_pc

sigma1 sigma2
0.7798 0.6977

ratio1_sigma_hn

sigma1 sigma2
0.8729 0.9265

ratio2_sigma_hn

sigma1 sigma2
0.7774 0.6959

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.8458 0.8105

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.6344 0.4132

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.842 0.8141

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.633 0.4116

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0013 1.0011 1.001 1.001 1.0019 1.0022 1.0135
n.eff 5100.0000 7300.0000 11000.000 11000.000 1900.0000 1500.0000 170.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001
n.eff 5.400e+05 5.400e+05 5.400e+05 3.700e+05 1.100e+05 1.800e+05 39000.000

n_levels

500-500

4.2.4 N = 1000

summary_print(N = 1000, J = 2)

4.2.4.1 J = 2

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
1922.16 42.31 92315.65 32.39
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5430 0.0433 -1.5443 0.0446 -1.5437 0.0432 -1.5443 0.0446
beta12 2.0529 0.0422 2.0535 0.0421 2.0523 0.0422 2.0536 0.0421
beta13 1.0588 0.0458 1.0592 0.0461 1.0585 0.0459 1.0592 0.0461
beta14 -3.0300 0.0417 -3.0305 0.0423 -3.0298 0.0419 -3.0305 0.0423

ratio1_beta1_pc

-0.014 0.0299 0.0143 -0.0186

ratio1_beta1_hn

-0.0143 0.0301 0.0142 -0.0184

ratio2_beta1_pc

1.075 1.0351 1.011 1.0286

ratio2_beta1_hn

1.0819 1.0062 1.0042 0.995

ratio1_sigma_pc

sigma1 sigma2
-0.0166 -0.1335

ratio2_sigma_pc

sigma1 sigma2
1.0868 0.7449

ratio1_sigma_hn

sigma1 sigma2
-4e-04 -0.0972

ratio2_sigma_hn

sigma1 sigma2
1.1007 0.821

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.0142 -0.1327

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.9657 0.8996

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.0076 -0.0897

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9621 0.913

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0011 1.0009 1.0017 1.0009 1.0012 1.0012 1.0011
n.eff 8800.0000 11000.0000 2500.0000 11000.0000 5200.0000 5200.0000 7400.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 2.700e+05 5.400e+05 4.900e+05 4.500e+05 4.400e+05 3.600e+05 3.400e+05

n_levels

1000-2
summary_print(N = 1000, J = 5)

4.2.4.2 J = 5

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
1841.19 38.91 93681.92 36.81
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5351 0.0455 -1.5363 0.0457 -1.5346 0.0455 -1.5363 0.0457
beta12 2.0172 0.0430 2.0184 0.0434 2.0173 0.0430 2.0184 0.0434
beta13 0.9978 0.0460 0.9986 0.0474 0.9975 0.0460 0.9986 0.0474
beta14 -2.9929 0.0436 -2.9946 0.0437 -2.9932 0.0432 -2.9946 0.0437

ratio1_beta1_pc

-0.0376 0.0268 0.0236 -0.0323

ratio1_beta1_hn

-0.0373 0.0263 0.0235 -0.0324

ratio2_beta1_pc

1.0159 1.0553 1.0638 1.0275

ratio2_beta1_hn

1.0172 1.0344 1.0594 1.0102

ratio1_sigma_pc

sigma1 sigma2
-0.1576 -0.1273

ratio2_sigma_pc

sigma1 sigma2
0.5801 0.6254

ratio1_sigma_hn

sigma1 sigma2
-0.1769 -0.1686

ratio2_sigma_hn

sigma1 sigma2
0.5673 0.5666

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.1459 -0.1147

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.8248 0.8557

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.1715 -0.1606

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.8347 0.8307

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0009 1.0011 1.0009 1.001 1.0011 1.001 1.001
n.eff 11000.0000 10000.0000 11000.0000 11000.000 7400.0000 11000.000 11000.000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 5.400e+05 2.600e+05 5.400e+05 5.400e+05 5.400e+05 3.100e+05 2.700e+05

n_levels

1000-5
summary_print(N = 1000, J = 10)

4.2.4.3 J = 10

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
1835.19 37.55 92609.21 36.08
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5071 0.0446 -1.5109 0.0461 -1.5073 0.0447 -1.5109 0.0461
beta12 2.0590 0.0436 2.0611 0.0437 2.0587 0.0437 2.0611 0.0437
beta13 1.0171 0.0458 1.0184 0.0465 1.0170 0.0458 1.0183 0.0465
beta14 -3.0966 0.0431 -3.0984 0.0434 -3.0964 0.0429 -3.0984 0.0434

ratio1_beta1_pc

-0.0813 0.0543 0.0299 -0.0464

ratio1_beta1_hn

-0.0812 0.0544 0.0298 -0.0463

ratio2_beta1_pc

1.0728 1.0381 1.0282 1.0277

ratio2_beta1_hn

1.0732 1.0168 1.0313 1.0091

ratio1_sigma_pc

sigma1 sigma2
-0.0662 -0.0135

ratio2_sigma_pc

sigma1 sigma2
0.8348 0.8833

ratio1_sigma_hn

sigma1 sigma2
-0.0459 -0.0166

ratio2_sigma_hn

sigma1 sigma2
0.8509 0.8672

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.0601 -0.0056

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.9315 0.9464

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0388 -0.007

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9366 0.9316

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0009 1.0013 1.001 1.0009 1.0009 1.0012 1.0014
n.eff 11000.0000 4400.0000 11000.000 11000.0000 11000.0000 6800.0000 3900.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 1.100e+05 2.100e+05 4.100e+05 5.400e+05 5.400e+05 3.800e+05 5.400e+05

n_levels

1000-10
summary_print(N = 1000, J = 25)

4.2.4.4 J = 25

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
1801.8 37.91 90073.21 42
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5101 0.0442 -1.5164 0.0448 -1.5109 0.0439 -1.5164 0.0448
beta12 2.0039 0.0438 2.0071 0.0428 2.0038 0.0435 2.0072 0.0428
beta13 0.9910 0.0459 0.9974 0.0463 0.9915 0.0458 0.9974 0.0463
beta14 -3.0299 0.0431 -3.0335 0.0430 -3.0301 0.0431 -3.0335 0.0430

ratio1_beta1_pc

-0.1257 0.0778 0.1301 -0.08

ratio1_beta1_hn

-0.1258 0.0778 0.1301 -0.08

ratio2_beta1_pc

1.0502 1.0081 1.024 1.0034

ratio2_beta1_hn

1.0576 0.9804 1.0197 0.9738

ratio1_sigma_pc

sigma1 sigma2
-0.0224 -0.0136

ratio2_sigma_pc

sigma1 sigma2
0.9503 0.9515

ratio1_sigma_hn

sigma1 sigma2
-0.0174 -0.0031

ratio2_sigma_hn

sigma1 sigma2
0.9443 0.9597

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
-0.0209 -0.0114

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.9798 0.9752

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
-0.0151 -0.001

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.9709 0.9797

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0012 1.0017 1.0011 1.0009 1.0009 1.0018 1.0021
n.eff 6400.0000 2300.0000 6900.0000 11000.0000 11000.0000 2100.0000 1700.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001e+00
n.eff 5.400e+05 5.400e+05 5.400e+05 4.000e+05 5.400e+05 3.100e+05 1.900e+05

n_levels

1000-25
summary_print(N = 1000, J = 1000)

4.2.4.5 J = 1000

Parameters Hyperparameters


times

JAGS dirinla pc LONG-JAGS dirinla hn
1900.09 42.22 94202.86 45.14
JAGS_mean JAGS_sd INLA_PC_mean INLA_PC_sd LONG_JAGS_mean LONG_JAGS_sd INLA_HN_mean INLA_HN_sd
beta11 -1.5240 0.0494 -1.5510 0.0455 -1.5239 0.0496 -1.5510 0.0454
beta12 1.9464 0.0492 1.9922 0.0438 1.9455 0.0486 1.9922 0.0438
beta13 0.9849 0.0492 0.9928 0.0461 0.9845 0.0495 0.9928 0.0461
beta14 -2.9883 0.0477 -3.0638 0.0438 -2.9884 0.0479 -3.0638 0.0437

ratio1_beta1_pc

-0.5465 0.9623 0.1674 -1.5717

ratio1_beta1_hn

-0.5464 0.9621 0.1675 -1.5716

ratio2_beta1_pc

0.8414 0.8324 0.8832 0.8317

ratio2_beta1_hn

0.8686 0.8152 0.8638 0.8161

ratio1_sigma_pc

sigma1 sigma2
0.7773 1.3511

ratio2_sigma_pc

sigma1 sigma2
0.9059 0.9123

ratio1_sigma_hn

sigma1 sigma2
0.7763 1.3439

ratio2_sigma_hn

sigma1 sigma2
0.9005 0.9126

ratio1_sigma_log_pc

log(sigma1) log(sigma2)
0.7618 1.2624

ratio2_sigma_log_pc

log(sigma1) log(sigma2)
0.8197 0.6906

ratio1_sigma_log_hn

log(sigma1) log(sigma2)
0.761 1.2561

ratio2_sigma_log_hn

log(sigma1) log(sigma2)
0.8147 0.6918

res_check_jags1

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.0009 1.001 1.0013 1.0012 1.0028 1.001 1.0069
n.eff 11000.0000 11000.000 5100.0000 6400.0000 1000.0000 11000.000 340.0000

res_check_jags2

beta1[1] beta1[2] beta1[3] beta1[4] deviance sigma1 sigma2
Rhat 1.001e+00 1.001e+00 1.001e+00 1.001e+00 1.001 1.001e+00 1.0011
n.eff 5.400e+05 5.400e+05 5.400e+05 5.400e+05 48000.000 2.500e+05 16000.0000

n_levels

1000-1000